*   Author:    	Annekatrin Deglow, Ralph Sundberg
*	Contact:   	annekatrin.deglow@pcr.uu.se, ralph.sundberg@pcr.uu.se
*	Do-file:   	ADRS_main_analysis.do
*   Dataset:   	ADRS_analysis.dta
*	Article:   	To Blame or To Support? Large-scale Insurgent Attacks on Civilians and Public Trust in State Institutions
*	Journal:	International Studies Quarterly

*-------------------------------------------------------------------------------
*	Program Setup 
*-------------------------------------------------------------------------------
clear
//set your working directory
version 15 
use "ADRS_analysis", clear
set more off
set scheme plotplain

*-------------------------------------------------------------------------------	
* Figure 1: Treatment and control group for the Kabul City sample
*-------------------------------------------------------------------------------
// Figure 1 is produced in R; see separate script ("ADRS_analysis.R")



*-------------------------------------------------------------------------------	
* Figure 2: Distribution of interviews by treatment and control group and sub-districts
*-------------------------------------------------------------------------------
// Figure 2 is produced in R; see separate script ("ADRS_analysis.R")



*-------------------------------------------------------------------------------	
* Figure 3: Balance tests
*-------------------------------------------------------------------------------
// Figure 3 is produced in R; see separate script ("ADRS_analysis.R")

logit	 treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 


*-------------------------------------------------------------------------------	
* Table 1: Ordered logistic regression models
*-------------------------------------------------------------------------------	
* x34r = trust in the local government
* x34l = trust in the parliament
* x34b = trust in the police

foreach y in x34r x34l x34b { 
									 		
	// Binary models (M1, M3, M5) 
	ologit  `y' treatment_dummy
	
	// Models with pre-treatment covariates (M2, M4, M6) 
	ologit  `y' treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 
}



*-------------------------------------------------------------------------------	
* Figure 4: Substantive Effects
*-------------------------------------------------------------------------------

foreach y in x34r x34l x34b { 
									 		
	// Main models (M1, M3, M6) 
	quietly ologit `y' i.treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 
	
	// Change in predicted probabilities
	margins, dydx(treatment_dummy) at(income=4 education=1 gender_dummy=1 radio_dummy=0 pashtun_dummy=0  age =35.78303) predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) predict(outcome(4)) vsquish 

	// Graph change in predicted probabilities (note: titles changed manually for each outcome)
	marginsplot, yline(0, lcolor(red)) plotopts(mcolor(black) msymbol(o)) level(95) title("") recast(scatter) ///
	xtitle("",size(small)) ///
	ytitle("Change in predicted probability",size(small))  ///
	xlabel(1 "None" 2 "Not very much" 3 "A fair amount" 4 "A great deal" ,labsize(vsmall)) ///
	yscale(range(-0.15(0.05)0.15)) ylabel(-0.15(0.05)0.15) 
}


foreach y in x34r x34l x34b { 
									 		
	// Main models (M1, M3, M6) 
	quietly ologit `y' i.treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 

	// Predicted probabilities for each outcome category
	margins, at (treatment_dummy = (0 1) income=4 education=1 gender_dummy=1 radio_dummy=0 pashtun_dummy=0  age =35.78303) predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) predict(outcome(4))
}


*-------------------------------------------------------------------------------	
* Table 2: Observable implications of mechanisms
*-------------------------------------------------------------------------------
* pref_false    = Preference Falsification
* threat        = Threat perception
* authoritarian = Authoritarian attitudes

// M1: Preference falsificatiom
	ologit pref_fals treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 

// M2: Threat perception
	ologit threat treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 

// M3: Authoritarian attitudes
	logit authoritarian treatment_dummy gender_dummy age radio_dummy pashtun_dummy i.income i.education 




